# 生成器函数
def test_gen():
    li = []
    yield 'a'
    yield 'b'
    yield 'c'


def test_gen2(n):
    li = []
    for i in range(n):
        li.append(i)
        yield li


if __name__ == "__main__":
    # 生成器表达式
    gen = (i*5 for i in range(5))
    print(gen)
    print(gen.__next__())
    print(next(gen))
    for i in gen:
        print(i)

    gen01 = test_gen()
    print(next(gen01))
    print(next(gen01))
    print(next(gen01))

    gen02 = test_gen2(10)
    print(next(gen02))
    print(next(gen02))
    print(next(gen02))
    print(next(gen02))
    print(next(gen02))